import { likeDoctor } from "@/apis/consult"
import type { DoctorItem, KnowledgeType, LikeDoctorType } from "@/types/consult"
import { ref } from "vue"

export const useLike =(type:LikeDoctorType='doc')=>{
  const loading = ref(false)
  const likeBtn = async (item: DoctorItem | KnowledgeType) => {
  loading.value = true
  try {
    await likeDoctor(item.id,type)
    item.likeFlag = item.likeFlag === 1 ? 0 : 1
  } finally {
    loading.value = false
  }
}
 return {
  loading,
  likeBtn
 }
}